//
// Created by yangchao on 2022/5/9.
// 55. 跳跃游戏: https://leetcode.cn/problems/jump-game/
//

#include <vector>
#include <cstring>

using namespace std;

class CanJump{
public:
    bool canJump(vector<int>& nums) {
        bool dp[nums.size()];
        memset(dp, false,sizeof (dp));
        dp[0] = true;
        for (int i = 1; i < nums.size(); ++i) {
            for (int j = i-1; j >= 0; --j) {
                if (dp[j] && nums[j] >= i-j) {
                    dp[i] = true;
                    break;
                }
            }
        }
        return dp[nums.size() - 1];
    }
};

